home *** CD-ROM | disk | FTP | other *** search
/ PC-SIG Library 8 / PC-SIG Library CD-ROM (8th Edition) (1990-04).iso / 201_300 / disk0258 / z.asm < prev    next >
Encoding:
Assembly Source File  |  1983-10-01  |  1.4 KB  |  78 lines

  1.     page    ,132
  2. ; Z s
  3. ;    "Sleep" for s seconds.  If s omitted, take five.
  4. ;
  5. cseg    segment    public 'code'
  6.     assume    cs:cseg,ds:cseg
  7.  
  8.     org    80h
  9. len    db    ?        ; length
  10.     db    ?        ; initial space if len>0
  11. param    db    ?        ; first digit
  12.  
  13.     org    100h
  14. Z    proc    far
  15.     mov    cl,len
  16.     cmp    cl,0
  17.     jz    until        ; parameter omitted; use default
  18.     xor    ax,ax        ; ax will be param in binary
  19.     xor    bh,bh
  20.     xor    ch,ch
  21.     dec    cl        ; cx = number of digits
  22.     mov    dl,10
  23.     lea    si,param    ; point to first digit
  24.  
  25. next:    mul    dl        ; push seen digits left one place
  26.     mov    bl,[si]
  27.     and    bl,0FFh-'0'
  28.     add    ax,bx        ; add this digit to running sum
  29.     inc    si        ; point to next digit
  30.     loop    next
  31.     mov    wait,ax        ; save # secs to zzz
  32.  
  33. until:    mov    ah,2Ch        ; get time
  34.     int    21h        ; ch,cl= h,m; dh,dl= s,c
  35.     mov    athm,cx
  36.     mov    ats,dh
  37.  
  38.     xor    dx,dx        ; prepare for divide
  39.     mov    ax,wait
  40.     mov    bl,ats
  41.     add    ax,bx
  42.     mov    cx,60
  43.     div    cx        ; ax= mins; dx= secs
  44.     mov    ats,dl
  45.  
  46.     xor    dx,dx
  47.     mov    bl,atm
  48.     add    ax,bx
  49.     div    cx        ; ax= hrs; dx= mins
  50.     mov    atm,dl
  51.  
  52.     xor    dx,dx
  53.     mov    bl,ath
  54.     add    ax,bx
  55.     mov    cx,24
  56.     div    cx        ; ax= days; dx= hrs
  57.     mov    ath,dl        ; save hrs; discard days
  58.  
  59. check:    mov    ah,2Ch        ; get time
  60.     int    21h        ; ch,cl= h,m; dh,dl= s,c
  61.     cmp    cx,athm
  62.     jne    check
  63.     cmp    dh,ats
  64.     jl    check
  65.     int    20h        ; exit
  66.  
  67.     even
  68. wait    dw    5        ; how many seconds to wait
  69. athm    dw    ?
  70.     org    $-2
  71. atm    db    ?        ; minutes
  72. ath    db    ?        ; hours
  73. atc    db    ?        ; hundredths
  74. ats    db    ?        ; seconds
  75. Z    endp
  76. cseg    ends
  77.     end    Z
  78.